<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  <meta name="description" content="">
  <meta name="author" content="ThemeBucket">
  <link rel="shortcut icon" href="#" type="../image/png">
  <title>Demo</title>

  <link rel="stylesheet" href="../js/data-tables/DT_bootstrap.css" />
  <link rel="stylesheet" type="text/css" href="../js/bootstrap-timepicker/css/timepicker.css" />
  <link rel="stylesheet" type="text/css" href="../js/bootstrap-datetimepicker/css/datetimepicker-custom.css" />
  <link href="../css/style.css" rel="stylesheet">
  <link href="../css/style-responsive.css" rel="stylesheet">
</head>
<body class="sticky-header" onload="indexmenu('${oneMenu}','${twoMenu}');">
<%@ include file="../index/index.jsp" %>
<section>
	<div class="main-content">

        <!-- 地址栏-->
		<div class="page-heading">
            <h3>
                	后台管理系统
            </h3>
            <ul class="breadcrumb">
                <li>
                    <a href="#">任务管理</a>
                </li>
                <li class="active">下测量单</li>
            </ul>
        </div>   
		<!--这里是写一些内容的  -->
<h3>下测量订单:</h3>
<form id="defaultForm" class="form-horizontal" method="post">
               <div class="form-group">
                   <label class="col-md-2 col-sm-2 control-label">顾客姓名:</label>
                   <div class="col-md-4">
                       <input type="text" placeholder="顾客姓名" class="form-control" name="name">
                   </div>
               </div>
               <div class="form-group">
                   <label class="col-md-2 col-sm-2 control-label">电话:</label>
                   <div class="col-md-4">
                       <input type="text" placeholder="电话" class="form-control" name="phone">
                   </div>
               </div>
				<div class="form-group">
                   <label class="col-md-2 col-sm-2 control-label">测量时间:</label>
                   <div class="col-md-4">
                       <input size="16" type="text" value="2016-12-26 14:45:00" class="form_datetime form-control" name="subscribeTime">
                   </div>
               </div>
               <div class="form-group">
                   <label class="col-md-2 col-sm-2 control-label">房间数:</label>
                   <div class="col-md-4">
                       <input type="text" placeholder="房间数" class="form-control" name="roomNumB">
                   </div>
              </div>
               <div class="form-group">
                   <label class="col-md-2 col-sm-2 control-label">地址:</label>
				   			<div>    
				   				  	 
				                <div class="col-sm-2">	
				                    <select class="form-control" name="Province" id="Province" style="width: 129px;">
				                        <option value="999999">==省===</option>
				                    </select>
				                </div>
				                <div class="col-sm-2">
				                    <select class="form-control" name="City" id="City" style="width: 129px;">
				                        <option value="999999">==市===</option>
				                    </select>
				                </div>
				                <div class="col-sm-2">
				                    <select class="form-control" name="Village" id="Village" >
				                        <option>==县/区===</option>
				                    </select>
				                </div>
				            </div>
              </div>
                   
               <div class="form-group">
                   <label class="col-md-2 col-sm-2 control-label">详细地址</label>
                   <div class="col-md-4">
                       <input type="text" placeholder="详细地址" class="form-control" name="address">
                   </div>
               </div>       
               <div class="form-group">
                   <label class="col-md-2 col-sm-2 control-label">测量费</label>
                   <div class="col-md-4">
                       <input type="text" placeholder="测量费" class="form-control" name="indentPrice" disabled="disabled">
                   </div>
               </div>                                         
               <div class="form-group">
                   <label class="col-md-2 col-sm-2 control-label">增加费用</label>
                   <div class="col-md-4">
                       <input type="text" placeholder="增加费用" class="form-control" name="addPrice">
                   </div>
               </div>             
                                
</form>		
		<button class="btn btn-info finish" style="position: relative;margin-left: 1000px;" onclick="toAddRepairIndent()">下单</button>
		
		
		
		<!--内容结束  -->
	</div>
</section>


</body>

<script type="text/javascript" src="../js/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script> 

<!--pickers initialization-->
<script src="../js/pickers-init.js"></script>
<script type="text/javascript">
$("#City").change(function(){
	$("#Village>option").first().nextAll().remove();	
	if($("#City").val()==999999){
		$("#Village>option").first().nextAll().remove();	
	}else if($("#Province").val()==11){
		$.post("../chinaArea/getZhiXiaShiSonByParentId.do?code="+$("#Province").val(),
				function(data){
					$.each(data,function(i,option){
						$("#Village").append('<option value="'+option.code+'">'+option.name+'</option>');
					});
				},
				'json'
		);			
	}else if($("#Province").val()==12){
 		$.post("../chinaArea/getZhiXiaShiSonByParentId.do?code="+$("#Province").val(),
				function(data){
					$.each(data,function(i,option){
						$("#Village").append('<option value="'+option.code+'">'+option.name+'</option>');
					});
				},
				'json'
		);	 	
		$("#City").append('<option value="'+$("#Province").val()+'">'+$("#Province").html()+'</option>');
	}else if($("#Province").val()==31){
 		$.post("../chinaArea/getZhiXiaShiSonByParentId.do?code="+$("#Province").val(),
				function(data){
					$.each(data,function(i,option){
						$("#Village").append('<option value="'+option.code+'">'+option.name+'</option>');
					});
				},
				'json'
		); 		
		$("#City").append('<option value="'+$("#Province").val()+'">'+$("#Province").html()+'</option>');
	}else{
		$.post(
				"../chinaArea/getAllSonByParentId.do?code="+$("#City").val(),
				function(data){
					$.each(data,function(i,option){
						$("#Village").append('<option value="'+option.code+'">'+option.name+'</option>');
					});
				},
			'json'
		);		
	}
			
});

$("#Province").change(function(){
	$("#City>option").first().nextAll().remove();	
	if($("#Province").val()==999999){
		$("#Village>option").first().nextAll().remove();	
	}else if($("#Province").val()==11){
		$("#City").append('<option value="11">北京市</option>');
	}else if($("#Province").val()==12){
		$("#City").append('<option value="12">天津市</option>');
	}else if($("#Province").val()==31){	
		$("#City").append('<option value="31">上海市</option>');
	}else{
		$.post(
				"../chinaArea/getAllSonByParentId.do?code="+$("#Province").val(),
				function(data){
					$.each(data,function(i,option){
						$("#City").append('<option value="'+option.code+'">'+option.name+'</option>');
					});
				},
			'json'
		);	
	}
});



$(document).ready(function(){
	$("#Province>option").first().nextAll().remove();	
		$.post(
		"../chinaArea/getAllSheng.do",
		function(data){
			//这是所有的省份
			$.each(data,function(i,options){
				if(options.code==71){
					
				}else if(options.code==81){
					
				}else if(options.code==82){
					
				}else{
					$("#Province").append('<option value="'+options.code+'">'+options.name+'</option>');
				}
				
			});
		},
		'json'
	
	); 
	
});
//操作成功之后提示
function success(text){
	  $("#alerts").html("<div  style='text-align: center; display:no;' class='alert alert-success alert-dismissable'><strong>"+text+"</strong></div>");
	  $("#menus").click();
 
}
//操作失败之后提示

function fail(text){
	  $("#alerts").html("<div  style='text-align: center; display:no;' class='alert alert-success alert-dismissable'><strong>"+text+"</strong></div>");
	  $("#menus").click();

}
function myfresh(){
	window.location.href=window.location.href;
}	
//得到选择的地址,和房间数得到该测量费
$("#City").change(function(){
	var province=$("#Province").val();
	var city=$("#City").val();
	//房间数
	var roomNumber=$("input[name='roomNumB']").val();
	//根据城市, 得到测量费的计算
	$.post(
		"../taskManage/getTerritoryByCode.do",
		{
			province:province,
			city:city
		},
		function(data){
			var celiangMoney=0;
			if(roomNumber<=data.roomNumber){
				celiangMoney=data.measureM;
			}else{
				celiangMoney=data.measureM+data.dmeasureM*(roomNumber-data.roomNumber);
			}
			$("input[name='indentPrice']").val(celiangMoney);
		},
		"json"
	);
	
	
});





function toAddRepairIndent(){
	$.post(
			"../taskManage/toAddMeasureIndent.do",
			$("#defaultForm").serialize(),
			function(data){
				if(data==1){
					success("添加测量订单成功!");
					setTimeout(myfresh,2000);
				}
			},
			"json"
			
		);
}
	

</script>
</html>
